import { defineStore } from 'pinia';

/**
 * 认证信息
 */
export interface AuthenticationState {
  /**
   * 访问Token
   */
  accessToken: Nullable<string>;
}

export const useAuthenticationStore = defineStore({
  id: 'app-authentication',
  state: (): Partial<AuthenticationState> => {
    return {
      accessToken: null,
    };
  },
  getters: {
    /**
     * 判断是否已经登录
     */
    isLoggedIn(): boolean {
      return !!this.accessToken;
    },
  },
  actions: {},
});
